Genderize Special:Preferences
authorPavel Selitskas <p.selitskas@gmail.com>
Sun, 2 Dec 2012 21:31:30 +0000 (00:31 +0300)
committerPavel Selitskas <p.selitskas@gmail.com>
Thu, 6 Dec 2012 20:52:30 +0000 (23:52 +0300)
GENDER support added for messages:
* username
* uid
* prefs-memberingroups

These messages require GENDER for grammatically correct sentences
at least in some Slavic languages. Perhaps, other languages may
require its support in other messages as well (e.g. yourrealname).

+ Some refactoring per review request.

Change-Id: I51cc8ea9128dda90d87de656ea3a4605a5dc04e0

includes/Preferences.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php

index a3c684b..6725848 100644 (file)
@@ -158,18 +158,21 @@ class Preferences {
                        $wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication,
                        $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress;
 
+               // retrieving user name for GENDER and misc.
+               $userName = $user->getName();
+
                ## User info #####################################
                // Information panel
                $defaultPreferences['username'] = array(
                        'type' => 'info',
-                       'label-message' => 'username',
-                       'default' => $user->getName(),
+                       'label-message' => array( 'username', $userName ),
+                       'default' => $userName,
                        'section' => 'personal/info',
                );
 
                $defaultPreferences['userid'] = array(
                        'type' => 'info',
-                       'label-message' => 'uid',
+                       'label-message' => array( 'uid', $userName ),
                        'default' => $user->getId(),
                        'section' => 'personal/info',
                );
@@ -185,7 +188,7 @@ class Preferences {
                        $groupName  = User::getGroupName( $ueg );
                        $userGroups[] = User::makeGroupLinkHTML( $ueg, $groupName );
 
-                       $memberName = User::getGroupMember( $ueg, $user->getName() );
+                       $memberName = User::getGroupMember( $ueg, $userName );
                        $userMembers[] = User::makeGroupLinkHTML( $ueg, $memberName );
                }
                asort( $userGroups );
@@ -196,7 +199,7 @@ class Preferences {
                $defaultPreferences['usergroups'] = array(
                        'type' => 'info',
                        'label' => $context->msg( 'prefs-memberingroups' )->numParams(
-                               count( $userGroups ) )->parse(),
+                               count( $userGroups ) )->params( $userName )->parse(),
                        'default' => $context->msg( 'prefs-memberingroups-type',
                                $lang->commaList( $userGroups ),
                                $lang->commaList( $userMembers )
@@ -507,14 +510,15 @@ class Preferences {
                # be nice to somehow merge this back in there to avoid redundancy.
                if ( $wgAllowUserCss || $wgAllowUserJs ) {
                        $linkTools = array();
+                       $userName = $user->getName();
 
                        if ( $wgAllowUserCss ) {
-                               $cssPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/common.css' );
+                               $cssPage = Title::makeTitleSafe( NS_USER, $userName . '/common.css' );
                                $linkTools[] = Linker::link( $cssPage, $context->msg( 'prefs-custom-css' )->escaped() );
                        }
 
                        if ( $wgAllowUserJs ) {
-                               $jsPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/common.js' );
+                               $jsPage = Title::makeTitleSafe( NS_USER, $userName . '/common.js' );
                                $linkTools[] = Linker::link( $jsPage, $context->msg( 'prefs-custom-js' )->escaped() );
                        }
 
@@ -1009,27 +1013,17 @@ class Preferences {
                        'section' => 'searchoptions/advancedsearchoptions',
                );
 
-               $nsOptions = array();
-
-               foreach ( $wgContLang->getNamespaces() as $ns => $name ) {
-                       if ( $ns < 0 ) {
-                               continue;
-                       }
-
-                       $displayNs = str_replace( '_', ' ', $name );
-
-                       if ( !$displayNs ) {
-                               $displayNs = $context->msg( 'blanknamespace' )->text();
-                       }
-
-                       $displayNs = htmlspecialchars( $displayNs );
-                       $nsOptions[$displayNs] = $ns;
+               $nsOptions = $wgContLang->getFormattedNamespaces();
+               $nsOptions[0] = $context->msg( 'blanknamespace' )->text();
+               foreach ( $nsOptions as $ns => $name ) {
+                       if ( $ns < 0 )
+                               unset( $nsOptions[$ns] );
                }
 
                $defaultPreferences['searchnamespaces'] = array(
                        'type' => 'multiselect',
                        'label-message' => 'defaultns',
-                       'options' => $nsOptions,
+                       'options' => array_flip( $nsOptions ),
                        'section' => 'searchoptions/advancedsearchoptions',
                        'prefix' => 'searchNs',
                );
index 09e0ad0..cd3ef1a 100644 (file)
@@ -1890,9 +1890,9 @@ This cannot be undone.',
 'prefs-emailconfirm-label'      => 'E-mail confirmation:',
 'prefs-textboxsize'             => 'Size of editing window',
 'youremail'                     => 'E-mail:',
-'username'                      => 'Username:',
-'uid'                           => 'User ID:',
-'prefs-memberingroups'          => 'Member of {{PLURAL:$1|group|groups}}:',
+'username'                      => '{{GENDER:$1|Username}}:',
+'uid'                           => '{{GENDER:$1|User}} ID:',
+'prefs-memberingroups'          => '{{GENDER:$2|Member}} of {{PLURAL:$1|group|groups}}:',
 'prefs-memberingroups-type'     => '$1', # only translate this message to other languages if you have to change it
 'prefs-registration'            => 'Registration time:',
 'prefs-registration-date-time'  => '$1', # only translate this message to other languages if you have to change it
index 9dfe974..97e365c 100644 (file)
@@ -1576,9 +1576,13 @@ Shown as legend of the second fieldset of the tab 'Search' in [[Special:Preferen
 'youremail' => 'Label of the e-mail text box of the "E-mail options" section of "Special:Preferences".
 
 {{Identical|E-mail}}',
-'username' => '{{Identical|Username}}',
-'uid' => '{{Identical|User ID}}',
-'prefs-memberingroups' => 'This message is shown on [[Special:Preferences]], first tab. See also {{msg-mw|prefs-memberingroups-type}}.',
+'username' => 'Username field in [[Special:Preferences]]. $1 is the current user name for GENDER distinction (depends on sex setting).
+
+{{Identical|Username}}',
+'uid' => 'User ID field in [[Special:Preferences]]. $1 is the current user name for GENDER distinction (depends on sex setting).
+
+{{Identical|User ID}}',
+'prefs-memberingroups' => 'This message is shown on [[Special:Preferences]], first tab. See also {{msg-mw|prefs-memberingroups-type}}. $2 is the user name for GENDER.',
 'prefs-memberingroups-type' => '{{optional}}
 Parameters:
 * $1 is list of group names